feat: Add initial support for YouTube clip links - #9532
Conversation
Pull request was converted to draft
613257f to
1644ed0
Compare
Pull request was converted to draft
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
2dba6f2 to
9d63ca8
Compare
|
Conflicts have been resolved. A maintainer will review the pull request shortly. |
|
Can be undrafted :) |
9d63ca8 to
9f06cb5
Compare
Co-authored-by: Cameron Radmore <radmorecameron@gmail.com>
|
Both the Invidious and local api should be working now. Issue was a mix of typo + updating the name of a param in my YouTube.js PR and forgetting to reflect that change here. |
| const parsedParams = ClipParams.decode(Utils.base64ToU8(decodeURIComponent(clipResponse.payload.params))) | ||
|
|
||
| return { | ||
| videoId, | ||
| startTime: parsedParams.clipParamData.startTime / 1000, // convert to seconds | ||
| endTime: parsedParams.clipParamData.endTime / 1000, // convert to seconds | ||
| clipTitle: parsedParams.clipParamData.clipTitle, | ||
| clipMetadata: parsedParams.clipParamData.clipMetadata | ||
| } |
There was a problem hiding this comment.
As this section of the code is the same for the local and Invidious APIs apart from where the video ID and params string is read from, could you please extract it into a shared function that takes the video ID and params text as the input, decodes it and returns the object.
| export async function getClipInvidious(clipId) { | ||
| const response = await resolveUrl('https://www.youtube.com/clip/' + clipId) | ||
|
|
||
| const parsedParams = ClipParams.decode(Utils.base64ToU8(decodeURIComponent(response.params))) |
There was a problem hiding this comment.
As we cannot treeshake YouTube.js because of Options API components, we exclude the entire YouTube.js dependency in builds where SUPPORTS_LOCAL_API is false (that's also why we use the repairInvidiousManifest function in those builds instead of generating a DASH manifest with YouTube.js). So you either need to gate the Invidious functionality here behind SUPPORTS_LOCAL_API too or use the Invidious clips API endpoint (I know that you originally avoided it here because of performance concerns on their side but using it as a fallback is probably okay).


Pull Request Type
Related issue
#4323
Description
This PR adds initial support for clip links.
Testing
Desktop